package org.xp.judgeplatform.pojo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum JudgeStatus {
    ACCEPTED("AC", "答案正确"),
    PARTIAL_ACCEPTED("PA", "部分正确"),
    WRONG_ANSWER("WA", "答案错误"),
    TIME_LIMIT_EXCEEDED("TLE", "超时"),
    MEMORY_LIMIT_EXCEEDED("MLE", "内存超限"),
    RUNTIME_ERROR("RE", "运行时错误"),
    COMPILE_ERROR("CE", "编译错误"),
    SYSTEM_ERROR("SE", "系统错误"),
    PENDING("PENDING", "等待中"),
    JUDGING("JUDGING", "判题中");

    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举值
     */
    public static JudgeStatus fromCode(String code) {
        for (JudgeStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return SYSTEM_ERROR; // 默认返回系统错误
    }
}